From e4e175c892a5030b6ee10aeab90bc83719ecdbca Mon Sep 17 00:00:00 2001
From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Note: This portion of babl has still not received rigorous
+ testing, the main development of babl is still focused on internal
+ infrastructure work. As the development of babl allows, initial tests
+ and usage of babl is welcome; as it would help kill of random
+ mystypes in constants and such earlier, and make it a more valid
+ actual regression suite.
+ Core
-
@@ -86,7 +95,7 @@
At compile, load and runtime; babl is extendable with:
The simplest scenario for using babl is converting between linear buffers represented by an existing BablPixelFormat.
-
-#include <babl.h>
-
-unsigned char srgb_buf[WIDTH*HEIGHT*3];
-float lab_buf[WIDTH*HEIGHT*3];
-...
-
-babl_init (); /* initialize babl library */
-
-...
-
-Babl *babl_fish = babl_fish (babl_pixel_format ("srgb"),
- babl_pixel_format ("lab-float"));
-
-babl_fish_process (fish, srgb_buf, lab_buf, WIDTH * HEIGHT);
-
-...
+ babl_process (babl_fish ("srgb", "lab-float"),
+ srgb_buffer, lab_buffer,
+ pixel_count);
+
+ If the existing pixel formats are not sufficient for your conversion
+ needs, new ones can be created and named on the fly. The constructor
+ will provide the prior created one if duplicates are registered.
+ babl_format_new ("bgr-u8",
+ babl_model ("rgb"),
+ babl_type ("u8"),
+ babl_component ("B"),
+ babl_component ("G"),
+ babl_component ("R"),
+ NULL);
+
+ Instead of a linear buffer you can an image descriptor which desribes the start of the memory segment, the pitch in bytes between samples, and the rowstride (optionally 0 for unlimited).
+
+ babl_process (babl_fish ("srgb", "y'cbcr420p"),
+ srgb_buffer,
+ babl_image ("Y'", luma_buffer, 1, 0,
+ "Cb", cb_buffer, 1, 0,
+ "Cr", cr_buffer, 1, 0,
+ NULL);
+
-babl_destroy (); /* deinitialize babl library */
-
For more code samples look in the tests directory.
For samples of how the current internal api of specification of - data types, color models, pixel formats and their conversions look - in the babl/base/ directory. The tables in this HTML file is directly generated - based on the data registered by BablBase. + data types, color models, and conversions look in the babl/base/ + directory. The tables in this HTML file is directly generated + based on the data registered by BablBase. The API's used are very + similar in style to the API's described under the Usage section.
-For now, the only way to extend babl is from the application using the library, - by structuring your code in a similar fashion to BablBase it should be easier - to later turn it into a loadable module. +
For now, the only way to extend babl is from the application + using the library, by structuring your code in a similar fashion + to BablBase it should be easier to later turn it into a loadable + module.
@@ -210,7 +229,7 @@ babl_destroy (); /* deinitialize babl library */ NB: the modules will be loaded from the directories pointed to by the path in reverse order, this should allow the user to override - system wide installed types, models and pixel formats. + system wide definitions for types, models and formats.